package com.ftg.mall.service.impl.pms;

import com.ftg.mall.base.util.tools.ConvertUtil;
import org.springframework.stereotype.Service;
import com.ftg.mall.base.entity.pms.ProductCategory;
import com.ftg.mall.base.util.tooltips.ResBean;
import com.ftg.mall.mapper.pms.ProductCategoryMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ftg.mall.service.pms.IProductCategoryService;
import com.ftg.mall.vo.ProductCategoryVo;

import java.util.List;

/**
 * @author wangty
 * @date 2022/11/15
 */
@Service
public class ProductCategoryServiceImpl  extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements IProductCategoryService {


    @Override
    public ResBean showTreeWithCategory() {
        //数据库表里面的全部数据
        List<ProductCategory> list = this.baseMapper.selectList(null);
        //转换成为一个树
        List<ProductCategoryVo> tree = ConvertUtil.convertClass(list,ProductCategoryVo.class);
        //通过老程序  200优化成为了一行
        return ResBean.success(tree);
    }
}
